#ifndef BASE_HANDLER_H
#define BASE_HANDLER_H

/*该类为Hnadler类的基类，用户需实现read和write两个虚函数*/
class BaseHandler {
public:
	enum Type {WRITE, READ};
	void operator ()(int *size, char* buffer)
	{
		switch(type)
		{
			case READ:  read(size, buffer); break;
			case WRITE: write(size, buffer); break;
			default: break;
		}
	}
	void set_type(Type t) { type = t; };
	virtual void read(int *size, char* buffer) { };
	virtual void write(int *size, const char* buffer){ };		
	BaseHandler():type(READ){ };
	BaseHandler(Type t):type(t){ };
	virtual ~BaseHandler(){ };
private:
	Type type;
};
#endif
